#include <partical/ParticleFadeAffector.h>

namespace ne
{
    ParticleFadeAffector::ParticleFadeAffector()
        : ParticleAffector("ParticleFadeAffector")
    {
    }

    ParticleFadeAffector::ParticleFadeAffector(const ParticleFadeAffector &affector)
        : ParticleAffector(affector)
    {
    }

    bool ParticleFadeAffector::affectParticles(ParticleList &particleList, const real interval)
    {
        if (!ParticleAffector::affectParticles(particleList, interval)) return false;

        for (ParticleListIterator it=particleList.begin(); it!=particleList.end(); ++it)
        {
            Particle *pParticle = *it;
            pParticle->color.a = Math::Clamp(pParticle->color.a - interval / pParticle->totalLifetime);
        }

        return true;
    }

    ParticleFadeAffector::~ParticleFadeAffector()
    {
    }
}
